#!/usr/bin/python2.4
#
# Copyright 2011 Google Inc. All Rights Reserved.

"""Models for queries, tweets, scores, and reports.

Models representing both manually scored and predicted data.
"""

__author__ = 'vicfryzel@google.com (Vic Fryzel)'


from google.appengine.ext import db


class Query(db.Model):
    """Query requested by a user that needs scores predicted."""

    text = db.StringProperty()
    state = db.StringProperty()
    trained_at = db.DateTimeProperty()


class Tweet(db.Model):
    """Individual tweet and its relevant scores."""

    query = db.ReferenceProperty(Query)

    id = db.IntegerProperty()
    text = db.StringProperty()
    published_at = db.DateTimeProperty()

    predicted_at = db.DateTimeProperty()
    predicted_score = db.FloatProperty()

    # Used to get manual score average
    num_man_scores = db.IntegerProperty()
    agg_man_score = db.IntegerProperty()
    man_scored_at = db.DateTimeProperty()


class ReportEntry(db.Model):
    """Report entry used in graph generation."""

    query = db.ReferenceProperty(Query)

    sampled_at = db.DateTimeProperty()
    avg_score = db.FloatProperty()
    scores = db.ListProperty(int)
